<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //boolean向数字转化时，true为1，false为0
    //undefined转化为数字为NaN
    //null转换为数字 为0
    //可以使用parseInt parseFloat Number 来实现字符串转为数字类型，如果字符串为非纯数字，转换结果为NaN
    var b1=true;
    var b2=false;
    var result1=b1+0;
    var result2=b2+0;
    console.log(result1,result2);
    var u1=undefined;
    var result3=Number(u1);
    console.log(result3);
    var n1=null;
    var result4=Number(n1);
    console.log(result4);
    var str1="123";
    var str2="abc123";
    var result5=parseInt(str1);
    console.log(result5);
    var result6=parseInt(str2);
    console.log(result6);
</script>
</html>